package com.ruoyi.project.service;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.mapper.SongMapper;
import com.ruoyi.project.domain.Song;
import com.ruoyi.project.service.ISongService;
import com.ruoyi.common.support.Convert;

/**
 * 音乐曲目 服务层实现
 * 
 * @author ruoyi
 * @date 2018-11-01
 */
@Service
public class SongServiceImpl implements ISongService 
{
	@Autowired
	private SongMapper songMapper;

	/**
     * 查询音乐曲目信息
     * 
     * @param songId 音乐曲目ID
     * @return 音乐曲目信息
     */
    @Override
	public Song selectSongById(Long songId)
	{
	    return songMapper.selectSongById(songId);
	}
	
	/**
     * 查询音乐曲目列表
     * 
     * @param song 音乐曲目信息
     * @return 音乐曲目集合
     */
	@Override
	public List<Song> selectSongList(Song song)
	{
	    return songMapper.selectSongList(song);
	}
	
    /**
     * 新增音乐曲目
     * 
     * @param song 音乐曲目信息
     * @return 结果
     */
	@Override
	public int insertSong(Song song)
	{
	    return songMapper.insertSong(song);
	}
	
	/**
     * 修改音乐曲目
     * 
     * @param song 音乐曲目信息
     * @return 结果
     */
	@Override
	public int updateSong(Song song)
	{
	    return songMapper.updateSong(song);
	}

	/**
     * 删除音乐曲目对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
	@Override
	public int deleteSongByIds(String ids)
	{
		return songMapper.deleteSongByIds(Convert.toStrArray(ids));
	}

	/**
	 * 根据歌曲名查询信息
	 * @param songName
	 * @return
	 */
	@Override
	public Song selectSongsongname (String songName){
		Song song=new Song();
		song.setSongName(songName);
		List<Song> list=songMapper.selectSongList(song);
		if (list!=null){
			Song song1=list.get(0);
			return song1;
		}else {
			return null;
		}
	}



	/**
	 * 根据等级查询歌曲
	 * @param level
	 * @return
	 */
	@Override
	public List<Song> selectSonglevel (String level){
		Song song  = new Song();
		song.setLevel(level);

		return songMapper.selectSongList(song);
    }

	/**
	 * 根据星级查询信息
	 * @param starLevel
	 * @return
	 */
	@Override
	public List<Song> selectSongstarLevel(int starLevel){
		Song song=new Song();
		song.setStarLevel(starLevel);
		return songMapper.selectSongList(song);
	}

	
}
